package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.ImmRepertory;
import com.drug.mingkang.Mapper.ImmRepertoryMapper;
import com.drug.mingkang.service.ImmRepertoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ImmRepertory)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("immRepertoryService")
public class ImmRepertoryServiceImpl implements ImmRepertoryService {
    @Resource
    private ImmRepertoryMapper immRepertoryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param repertoryId 主键
     * @return 实例对象
     */
    @Override
    public ImmRepertory queryById(String repertoryId) {
        return this.immRepertoryMapper.queryById(repertoryId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ImmRepertory> queryAllByLimit(int offset, int limit) {
        return this.immRepertoryMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param immRepertory 实例对象
     * @return 实例对象
     */
    @Override
    public ImmRepertory insert(ImmRepertory immRepertory) {
        this.immRepertoryMapper.insert(immRepertory);
        return immRepertory;
    }

    /**
     * 修改数据
     *
     * @param immRepertory 实例对象
     * @return 实例对象
     */
    @Override
    public ImmRepertory update(ImmRepertory immRepertory) {
        this.immRepertoryMapper.update(immRepertory);
        return this.queryById(immRepertory.getRepertoryId());
    }

    /**
     * 通过主键删除数据
     *
     * @param repertoryId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String repertoryId) {
        return this.immRepertoryMapper.deleteById(repertoryId) > 0;
    }
}